package com.red.wood.module.evalMol.dao.Impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.red.wood.common.springjdbc.CommonDao;
import com.red.wood.module.evalMol.dao.AdoptCdnDao;

@Repository
public class AdoptCdnDaoImpl implements AdoptCdnDao{
	
	@Autowired
	private CommonDao dao;
	@Autowired
	private JdbcTemplate jdbcTemplate;

	@Override
	public void add(Map<String, Object> paramMap) {
		StringBuilder sqlSb = new StringBuilder();
		sqlSb.append("insert into t_eval_repY_cdnMol (");
		dao.insertTableData(paramMap, sqlSb);
	}

	@Override
	public void delete(String singleTaskId) {
		StringBuffer sql = new StringBuffer();
		if(StringUtils.isNotBlank(singleTaskId)){
			sql.append("delete from t_eval_repY_cdnMol where singleTaskId = "+ singleTaskId);
		}
		dao.deleteTableData(sql.toString());
	}
	
	@Override
	public Map<String, Object> getBySingleTaskId(String singleTaskId) {
		if(StringUtils.isNotBlank(singleTaskId)){
			String sql = "select singleTaskId,gameProvince,houseName,houseAddress,handleInfo,gbps from t_eval_repY_cdnMol where singleTaskId= " + singleTaskId;
			List<Map<String,Object>> dataList =  jdbcTemplate.queryForList(sql.toString());
			return dataList.get(0);
		} 
		return null;
	}

}
